<template>
  <section
    class="nb-step-wrapper-top"
    :style="{width: `${width}%`}"
  >
    <div class="nb-step-wrapper">
      <div
        class="step-item"
        v-for="(item, index) in steps"
        :class="[activity >= (index + 1) ? 'activity' : '']"
      >
        <div
          class="item"
        >{{index + 1}}</div>
        <div v-if="title.length" class="title">{{item}}</div>
      </div>
    </div>
    <div class="tips-step" v-if="tips">{{tips}}</div>
  </section>
</template>

<script>
  /**
   * length Number类型 title不存在时 需要传length
   * title 数组  title存在时 length无效
   * activity 当前步骤 Number 如：第一步 传 1
   * tips 可传注释
   * width 进度条宽度 默认100  百分比
   */
  export default {
    data () {
      return {
      }
    },
    props: {
      length: {
        type: Number,
        default: 0
      },
      title: {
        type: Array,
        default: () => {
          return []
        }
      },
      activity: {
        type: Number,
        default: 1
      },
      tips: {
        type: String,
        default: ''
      },
      width: {
        type: String,
        default: '100'
      }
    },
    computed: {
      steps () {
        return this.title.length ? this.title : this.length
      }
    },
    methods: {},
    mounted () {
    }
  }
</script>

<style lang="scss">
  .nb-step-wrapper-top{
    margin: 0 auto;
  }
.nb-step-wrapper{
  display: flex;
  justify-content: space-around;
  .step-item{
    flex: 1;
    text-align: center;
    display: flex;
    align-items: center;
    flex-direction: column;
    position: relative;
    .item{
      width: 50px;
      height: 50px;
      border-radius: 50%;
      background: rgb(235,246,254);
      line-height: 50px;
      color: #3da7f5;
      font-size: 25px;
      font-weight: 200;
      text-align: center;
      transition: all 0.3s linear;
      position: relative;
      z-index: 2;
    }
    .title{
      font-size: 14px;
      color: #666;
      padding-top: 10px;
    }
  }
  .activity{
    .item{
      background: rgb(61, 167, 245);
      color: white;
    }
  }
  .step-item:after{
    position: absolute;
    content: '';
    width: 100%;
    height: 4px;
    right: 50%;
    top: 23px;
    background: rgb(235,246,254);
  }
  .step-item:first-child:after{
    display: none;
  }
  .activity:after{
    position: absolute;
    content: '';
    width: 100%;
    height: 4px;
    right: 50%;
    top: 23px;
    background: rgb(61, 167, 245);
  }
  .activity:first-child:after{
    display: none;
  }
}
.tips-step{
  text-align: center;
  font-size: 12px;
  color: #999;
  padding-top: 10px;
}
</style>
